---
category: Level 1 — Basic
created: '2020-02-16'
keywords:
title: Remove all children of a node
---

## 1. Empty the inner HTML (not recommended)

```js
ele.innerHTML = '';
```

This method isn't recommended because it doesn't remove event handlers of child node. Hence, it might cause a memory leak if you are managing a big list of elements.

## 2. Remove child nodes

Remove its child node until it doesn't have any children.

```js
while (node.firstChild) {
    node.removeChild(node.firstChild);
}
```

## See also

-   [Remove an element](https://phuoc.ng/collection/html-dom/remove-an-element/)
-   [Unwrap an element](https://phuoc.ng/collection/html-dom/unwrap-an-element/)
